package gov.child.dao;

import gov.child.dao.exception.EntityDeleteException;
import gov.child.dao.exception.EntityQueryException;
import gov.child.dao.exception.EntitySaveException;
import gov.child.dao.exception.EntityUpdateException;
import gov.child.entities.po.EComplaint;
import gov.child.entities.po.EGuide;
import gov.child.entities.po.EUser;
import gov.child.entities.vo.Page;

import java.util.List;

/**
 * The interface Complaint dao. --finish
 *
 * @author fzh
 * @since 2017 /9/10
 */
public interface ComplaintDao extends Pageable {
    /**
     * 根据ID查询投诉条目
     *
     * @param id the id
     * @return the by id
     * @throws EntityQueryException the entity query exception
     */
    EComplaint findById(Integer id) throws EntityQueryException;

    /**
     * 查询全部投诉条目
     *
     * @return the all
     * @throws EntityQueryException the entity query exception
     */
    default List findAll() throws EntityQueryException {
        return findAll(Page.singlePage());
    }

    /**
     * 查询全部投诉条目(分页)
     *
     * @param page the page
     * @return the all
     */
    List findAll(Page page);

    /**
     * 根据Guide查询投诉条目
     *
     * @param guide the guide
     * @return the by guide
     * @throws EntityQueryException the entity query exception
     */
    default List findByGuide(EGuide guide) throws EntityQueryException {
        return findByGuide(guide, Page.singlePage());
    }

    /**
     * 根据Guide查询投诉条目（分页）
     *
     * @param guide the guide
     * @param page  the page
     * @return the by guide
     * @throws EntityQueryException the entity query exception
     */
    default List findByGuide(EGuide guide, Page page) throws EntityQueryException {
        return findByGuideId(guide.getId(), page);
    }

    default List findByGuideId(EGuide guide) throws EntityQueryException {
        return findByGuideId(guide.getId(), Page.singlePage());
    }

    List findByGuideId(Integer guideId, Page page) throws EntityQueryException;

    /**
     * 根据User查询投诉条目
     *
     * @param user the user
     * @return the by user
     * @throws EntityQueryException the entity query exception
     */
    default List findByUser(EUser user) throws EntityQueryException {
        return findByUser(user, Page.singlePage());
    }

    /**
     * 根据User查询投诉条目（分页）
     *
     * @param user the user
     * @param page the page
     * @return the by user
     * @throws EntityQueryException the entity query exception
     */
    default List findByUser(EUser user, Page page) throws EntityQueryException {
        return findByUserId(user.getId(), page);
    }

    default List findByUserId(Integer userId) throws EntityQueryException {
        return findByUserId(userId, Page.singlePage());
    }

    List findByUserId(Integer userId, Page page) throws EntityQueryException;

    /**
     * 保存投诉信息
     *
     * @param complaint the complaint
     * @throws EntitySaveException the entity save exception
     */
    void save(EComplaint complaint) throws EntitySaveException;

    /**
     * 删除投诉信息
     *
     * @param complaint the complaint
     * @throws EntityDeleteException the entity delete exception
     */
    void delete(EComplaint complaint) throws EntityDeleteException;

    /**
     * 更新投诉信息
     *
     * @param complaint the complaint
     * @throws EntityUpdateException the entity update exception
     */
    void update(EComplaint complaint) throws EntityUpdateException;
}
